import time


from  selenium import webdriver
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait

# 获取驱动
driver = webdriver.Edge()
# 通过驱动打开网页
driver.get("http://www.baidu.com")
# 隐式等待
driver.implicitly_wait(5)

# 获取当前时间
datestr1 = time.strftime("%Y%m%d%H%M%S",time.localtime())
print(datestr1)
# 截屏
driver.get_screenshot_as_file(f"d:\\baidu_{datestr1}.png")

# 二次定位
# 先获取父元素
fu = driver.find_element("id","s-top-left")
# 父元素的基础上再定位
ss = fu.find_elements("tag name","a")
for s in ss:
    print(s.text)